--1 REGION
SELECT
'MTD' TEMP, 
REGION,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({0}
) RAW
GROUP BY 1,2,3,4

UNION
--1 ORDERS
SELECT
'PMON' TEMP, 
REGION,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({1}
) RAW
GROUP BY 1,2,3,4

UNION
SELECT
'PMTD' TEMP, 
REGION,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({2}) RAW
GROUP BY 1,2,3,4
ORDER BY 1,2,3,4
;
--2 MARKET
SELECT
'MTD' TEMP, 
MARKET,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({0}
) RAW
GROUP BY 1,2,3,4

UNION
--1 ORDERS
SELECT
'PMON' TEMP, 
MARKET,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({1}
) RAW
GROUP BY 1,2,3,4

UNION
SELECT
'PMTD' TEMP, 
MARKET,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({2}) RAW
GROUP BY 1,2,3,4
ORDER BY 1,2,3,4
;
--3 STATE
SELECT
'MTD' TEMP, 
STATE,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({0}
) RAW
GROUP BY 1,2,3,4

UNION
--1 ORDERS
SELECT
'PMON' TEMP, 
STATE,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({1}
) RAW
GROUP BY 1,2,3,4

UNION
SELECT
'PMTD' TEMP, 
STATE,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({2}) RAW
GROUP BY 1,2,3,4
ORDER BY 1,2,3,4
;
--4 ACCT_MGR
SELECT
'MTD' TEMP, 
ACCT_MGR,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({0}
) RAW
GROUP BY 1,2,3,4

UNION
--1 ORDERS
SELECT
'PMON' TEMP, 
ACCT_MGR,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({1}
) RAW
GROUP BY 1,2,3,4

UNION
SELECT
'PMTD' TEMP, 
ACCT_MGR,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({2}) RAW
GROUP BY 1,2,3,4
ORDER BY 1,2,3,4
;
--5 PORTFOLIO
SELECT
'MTD' TEMP, 
PORTFOLIO,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({0}
) RAW
GROUP BY 1,2,3,4

UNION
--1 ORDERS
SELECT
'PMON' TEMP, 
PORTFOLIO,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({1}
) RAW
GROUP BY 1,2,3,4

UNION
SELECT
'PMTD' TEMP, 
PORTFOLIO,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({2}) RAW
GROUP BY 1,2,3,4
ORDER BY 1,2,3,4
;
--6 TRAC_ID
SELECT
'MTD' TEMP, 
TRAC_ID,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({0}
) RAW
GROUP BY 1,2,3,4

UNION
--1 ORDERS
SELECT
'PMON' TEMP, 
TRAC_ID,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({1}
) RAW
GROUP BY 1,2,3,4

UNION
SELECT
'PMTD' TEMP, 
TRAC_ID,
PRODUCT,
FEATURE,
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN PROD_QTY_U ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN PROD_QTY_U ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	({2}) RAW
GROUP BY 1,2,3,4
ORDER BY 1,2,3,4
;

